home *** CD-ROM | disk | FTP | other *** search
/ Ultra Pack / UltraComputing Partner Applications.iso / Maestro / bin / MakeMAEstroLinks < prev    next >
Text File  |  1996-01-14  |  998b  |  70 lines

  1. #! /bin/sh
  2.  
  3. USAGE="Usage: $0 fromdir [todir]"
  4.  
  5. if [ $# -lt 1 -o $# -gt 2 ]
  6. then
  7.     echo "$USAGE"
  8.     exit 1
  9. fi
  10.  
  11. DIRFROM=$1
  12.  
  13. if [ $# -eq 2 ];
  14. then
  15.     DIRTO=$2
  16. else
  17.     DIRTO=.
  18. fi
  19.  
  20. if [ ! -d $DIRTO ]
  21. then
  22.     echo "$0: $DIRTO is not a directory"
  23.     echo "$USAGE"
  24.     exit 2
  25. fi
  26.  
  27. cd $DIRTO
  28.  
  29. if [ ! -d $DIRFROM ]
  30. then
  31.     echo "$0: $DIRFROM is not a directory"
  32.     echo "$USAGE"
  33.     exit 2
  34. fi
  35.  
  36. pwd=`pwd`
  37.  
  38. if [ `(cd $DIRFROM; pwd)` = $pwd ]
  39. then
  40.     echo "$pwd: FROM and TO are identical!"
  41.     exit 1
  42. fi
  43.  
  44. for file in `ls -af $DIRFROM`
  45. do
  46.     if [ ! -d $DIRFROM/$file ]
  47.     then
  48.         ln -s $DIRFROM/$file .
  49.     else
  50.         if [ $file != RCS -a $file != SCCS -a $file != . -a $file != .. ]
  51.         then
  52.             echo $file:
  53.             mkdir $file
  54.             (cd $file
  55.              pwd=`pwd`
  56.              case "$DIRFROM" in
  57.                  /*) ;;
  58.                  *)  DIRFROM=../$DIRFROM ;;
  59.              esac
  60.              if [ `(cd $DIRFROM/$file; pwd)` = $pwd ]
  61.              then
  62.                 echo "$pwd: FROM and TO are identical!"
  63.                 exit 1
  64.              fi
  65.              $0 $DIRFROM/$file
  66.             )
  67.         fi
  68.     fi
  69. done
  70.